package com.ruoyi.web.controller.gxs;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.gxs.domain.GxsAwardtype;
import com.ruoyi.gxs.service.IGxsAwardtypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 奖励类型Controller
 * 
 * @author 高晓松
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/gxs/awardtype")
public class GxsAwardtypeController extends BaseController
{
    @Autowired
    private IGxsAwardtypeService gxsAwardtypeService;

    /**
     * 查询奖励类型列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:awardtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(GxsAwardtype gxsAwardtype)
    {
        startPage();
        List<GxsAwardtype> list = gxsAwardtypeService.selectGxsAwardtypeList(gxsAwardtype);
        return getDataTable(list);
    }

    /**
     * 导出奖励类型列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:awardtype:export')")
    @Log(title = "奖励类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxsAwardtype gxsAwardtype)
    {
        List<GxsAwardtype> list = gxsAwardtypeService.selectGxsAwardtypeList(gxsAwardtype);
        ExcelUtil<GxsAwardtype> util = new ExcelUtil<GxsAwardtype>(GxsAwardtype.class);
        util.exportExcel(response, list, "奖励类型数据");
    }

    /**
     * 获取奖励类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('gxs:awardtype:query')")
    @GetMapping(value = "/{gxsAwardTypeid}")
    public AjaxResult getInfo(@PathVariable("gxsAwardTypeid") Long gxsAwardTypeid)
    {
        return success(gxsAwardtypeService.selectGxsAwardtypeByGxsAwardTypeid(gxsAwardTypeid));
    }

    /**
     * 新增奖励类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:awardtype:add')")
    @Log(title = "奖励类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxsAwardtype gxsAwardtype)
    {
        return toAjax(gxsAwardtypeService.insertGxsAwardtype(gxsAwardtype));
    }

    /**
     * 修改奖励类型
     */
    //   @PreAuthorize("@ss.hasPermi('gxs:awardtype:edit')")
    @Log(title = "奖励类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxsAwardtype gxsAwardtype)
    {
        return toAjax(gxsAwardtypeService.updateGxsAwardtype(gxsAwardtype));
    }

    /**
     * 删除奖励类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:awardtype:remove')")
    @Log(title = "奖励类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gxsAwardTypeids}")
    public AjaxResult remove(@PathVariable Long[] gxsAwardTypeids)
    {
        return toAjax(gxsAwardtypeService.deleteGxsAwardtypeByGxsAwardTypeids(gxsAwardTypeids));
    }
}
